var models = require('../models');
var User = models.User;
var Topic = models.Topic;
var Reply = models.Reply;
var EventProxy = require('eventproxy');

//获取完整用户信息
exports.getFullUserById = function (id, callback) {
	var ep = new EventProxy();
	ep.fail(callback);

	User.findById(id, ep.done(function (user) {
		if (!user) return callback(null, '找不到该用户。');

		ep.all('topicCount', 'replyCount', function (topicCount, replyCount) {
			user.topicCount = topicCount;
			user.replyCount = replyCount;
			callback(null, '', user);
		});

		Topic.count({ authorId: user._id }, ep.done('topicCount'));
		Reply.count({ authorId: user._id }, ep.done('replyCount'))
		//todo:friends count
	}));
}